package com.netease.nie.base.http;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * 
 * @author KingsHunter
 * @createDate September 23rd,2016
 *
 */
@Configuration
public class AsyncHttpConfigInitializer {
	
	@Value("${http.async.http_timeout}")
	private int asyncHttpTimeOut;
	
	@Value("${http.async.http_connect_timeout}")
	private int asyncHttpConnectTimeout;
	
	@Value("${http.async.http_tcp_no_delay}")
	private boolean asyncHttpTcpNoDelay;
	
	@Value("${http.async.http_keep_alive}")
	private boolean asyncHttpKeepAlive;
	
	@Value("${http.async.http_callback_pool}")
	private int asyncHttpCallbackPool;
	
	@PostConstruct
	public void initAsyncHttpTimeOut() {
		AsyncHttpConfig.HTTP_TIMEOUT = this.asyncHttpTimeOut;
	}
	
	@PostConstruct
	public void initAsyncHttpConnectTimeOut() {
		AsyncHttpConfig.HTTP_CONNECT_TIMEOUT = this.asyncHttpConnectTimeout;
	}
	
	@PostConstruct
	public void initAsyncHttpTcpNoDelay() {
		AsyncHttpConfig.HTTP_TCP_NO_DELAY = this.asyncHttpTcpNoDelay;
	}
	
	@PostConstruct
	public void initAsyncHttpKeepAlive() {
		AsyncHttpConfig.HTTP_KEEP_ALIVE = this.asyncHttpKeepAlive;
	}
	
	@PostConstruct
	public void initAsyncHttpCallbackPool() {
		AsyncHttpConfig.HTTP_CALLBACK_POOL = this.asyncHttpCallbackPool;
	}
}
